package com.base;

public class 对象相等 {
    static class Inner{
        String name;
        int attribute;
        public Inner(String n,int a){
            this.name=n;
            this.attribute=a;
        }
        //看看是否重写该方法 的差别
        @Override
        public boolean equals(Object obj) {
            Inner an=(Inner) obj;
            if(!name.equals(an.name)){
                return  false;
            }
            if(!(attribute==an.attribute)){
                return false;
            }
            return true;
        }
    }
    public static void main(String[] args) {
        Inner a=new Inner("asa",1);
        Inner b=new Inner("asa",1);
        System.out.println(a.hashCode());
        System.out.println(b.hashCode());
        System.out.println(a.equals(b));

        //每个string值似乎都对应一个hashcode
        String sa="sa";
        String sb="sb";
        System.out.println(sa.hashCode());
        System.out.println(sb.hashCode());
        System.out.println(sa.equals(sb));
    }
}
